<template>
    <h2>房号信息添加</h2>
    <table border="1">
        
       
        <tr>
            <td>房号</td>
            <td>
                <input  type="number" v-model="info.rnRoomnum"/>
            </td>
        </tr>
        <tr>
            <td>备注</td>
            <td>
               <textarea v-model="info.beizhu">

               </textarea>
            </td>
        </tr>
        <tr>
            <td>状态</td>
            <td>
                <input  type="radio" :value="true"  v-model="info.rnState"/>上架
                <input  type="radio" :value="false" v-model="info.rnState" />下架
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                
                <input  type="button" value="添加"  @click="Add" />
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
 import { ref } from 'vue';
 import axios from 'axios';

 const info=ref({
    "rnId": 0,
  
  "beizhu": "",
  "rnRoomnum": 0,
  "rnCreatetime": "2024-12-06T01:32:41.976Z",
  "rnState": true,
  "rnDel": true
 })

const Add=()=>{
    if(info.value.rnRoomnum==0){
        alert("房号不能为空");
        return;
    }
    
    axios.post("https://localhost:7010/api/RoomNum/AddRoomNum",info.value)
    .then(res=>{
        if(res.data>0){
            alert('添加成功');
        }
       else if(res.data==-1){
            alert('房号名称重复');
        }
        else{
            alert('添加失败');
        }
    })
}

</script>